﻿@page "/locators"
@inject IStringLocalizer<Locators> Localizer

<h3>@Localizer["Title"]</h3>

<h4>@Localizer["SubTitle"]</h4>

<DemoBlock Title="@Localizer["BasicUsageTitle"]" Introduction="@Localizer["BasicUsageIntro"]" Name="Normal">
    <p><b>@Localizer["BasicUsageP1"]</b></p>
    <div class="mb-3">
        <p>@((MarkupString)Localizer["BasicUsageP2"].Value)</p>
        <Pre>[Inject]
[NotNull]
private IIPLocatorProvider? IPLocator { get; set; }
</Pre>
    </div>
    <Tips>
        <div>@((MarkupString)Localizer["BasicUsageP3"].Value)</div>
        <div><b>@Localizer["BasicUsageP4"]</b></div>
        <div>@((MarkupString)Localizer["BasicUsageP5"].Value)</div>
    </Tips>
    <Pre>Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)</Pre>
    <div class="mb-2">@Localizer["BasicUsageP6"]</div>
    <div><code>112.224.74.239</code> @Localizer["BasicUsageP7"]</div>
    <div class="mb-3"><code>183.160.236.53</code> @Localizer["BasicUsageP8"]</div>
    <div class="row g-3 form-inline">
        <div class="col-12 col-sm-6">
            <BootstrapInput @bind-Value="Ip" DisplayText="@Localizer["BasicUsageInputText"]" ShowLabel="true" />
        </div>
        <div class="col-12 col-sm-6">
            <Display Value="Location" DisplayText="@Localizer["BasicUsageDisplayText"]" ShowLabel="true" />
        </div>
        <div class="col-12">
            <Button Icon="fa-solid fa-location-arrow" Text="@Localizer["BasicUsageButtonText"]" OnClick="OnClick" />
        </div>
    </div>
    <p class="mt-3"><b>@Localizer["BasicUsageP9"]</b></p>
    <div>
        <p><b>@Localizer["BasicUsageP10"]</b></p>
        <Pre>private class CustomerLocator : IIPLocator
{
    public Task&lt;string&gt; Locate(IPLocatorOption option)
    {
        throw new NotImplementedException();
    }
}</Pre>
        <p><b>@Localizer["BasicUsageP11"]</b></p>
        <Pre>public void ConfigureServices(IServiceCollection services)
{
    services.AddBootstrapBlazor(locatorAction: option =>
    {
        option.LocatorFactory = provider => new CustomerLocator();
    });
}</Pre>
        <div>@((MarkupString)Localizer["BasicUsageP12"].Value)</div>
    </div>
</DemoBlock>
